# Contributor: David Demelier <markand@malikania.fr>
# Maintainer: David Demelier <markand@malikania.fr>
pkgname=wesnoth
pkgver=1.16.2
_major=${pkgver%.*}
pkgrel=2
pkgdesc="turn-based strategy game in fantasy world"
url="https://www.wesnoth.org"
arch="all !riscv64" # textrel on rv64
license="GPL-2.0-only"
makedepends="
	boost-dev
	cairo-dev
	cmake
	dbus-dev
	fontconfig-dev
	libvorbis-dev
	openssl-dev
	pango-dev
	readline-dev
	samurai
	sdl2-dev
	sdl2_image-dev
	sdl2_mixer-dev
	"
subpackages="$pkgname-doc"
source="https://sourceforge.net/projects/wesnoth/files/wesnoth-$_major/wesnoth-$pkgver/wesnoth-$pkgver.tar.bz2
	fix-segfault.patch
	"
options="!check" # No tests

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=Release \
		$CMAKE_CROSSOPTS
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
bb1c307981de4990fc341310b358c5e1c54673d7434bc0a0fa0a7b5caf11e6db3255ad0eb57b6b188ff6ab8f287321fc8821813d0ef3661cfa637985070bb540  wesnoth-1.16.2.tar.bz2
8fc0f43719d0a5b7554a027f4367d5c7459549741b82c3c879385dd5c8e10e96a2064f329090ac2a0a5e853d5591a7ecd0ce650748f597cd81a90fb7d11581ae  fix-segfault.patch
"
